<?php
namespace Home\Model;

use Think\Model;

class OrdersModel extends Model
{
	protected $_validate = array(
		
	);



	protected $_auto = array(
		
		array('addtime','time',1,'function'),//创建时间
		array('user_id',"user_id",1,'callback'),
		array('cart_ids','cart_ids',1,'callback'),
		array('order_number','order_number',1,'callback')

	);


	function user_id(){
		return session('user_id');
	}

	function cart_ids(){
		return session('cart_ids');
	}
	
	function order_number(){
		$c = range('0','9');
		$num = '';
		for ($i=0; $i < 14; $i++) { 
			$num .= $c[array_rand($c)];
		}
		return $num;
	}
    //不为空
	function chk_require($val){

		$rule = '/\S+/';
		if(!preg_match($rule,$val)){
            return false;
        }
	}

	function chk_province($val){

		if($val == '省份'){
            return false;
        }
	}
	function chk_city($val){

		if($val == '地级市' ){
            return false;
        }
	}
	function chk_county($val){

		if($val == '市、县级市'){
            return false;
        }
	}

	//手机格式验证
	function chk_phone($phone){

		$rule = '/^1([358][0-9]|4[579]|66|7[0135678]|9[89])[0-9]{8}$/';
		if(!preg_match($rule,$phone)){
            return false;
        }
	}


	

}
?>